<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
body {
	background-color: #eff3f6;
}

form.gs4 {
	background: -webkit-gradient(linear, bottom, left 175px, from(#CCCCCC), to(#EEEEEE));
	background: -moz-linear-gradient(bottom, #CCCCCC, #EEEEEE 175px);
	margin: auto;
	position: absolute;
	width: 730px;
	height: 250px;
	font-family: Tahoma, Geneva, sans-serif;
	font-size: 14px;
	font-style: italic;
	line-height: 24px;
	font-weight: bold;
	color: #000;
	text-decoration: none;
	-webkit-border-radius: 10px;
	-moz-border-radius: 10px;
	border-radius: 10px;
	padding: 10px;
	border: 1px solid #999;
	border: inset 1px solid #333;
	-webkit-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
	-moz-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
	box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
	top: -19px;
}
input.subgs4 {
	width: 190px;
	background: #660000;
	color: #fff;
	font-family: Tahoma, Geneva, sans-serif;
	height: 30px;
	-webkit-border-radius: 15px;
	-moz-border-radius: 15px;
	border-radius: 15px;
	border: 1p solid #999;
	background-color: #003366;
}
input.period    {
width:180px;
display:block;
border: 1px solid #999;
height: 25px;
-webkit-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
}
</style>
</head>

<body>
<?php
$dis="<div style=\"position:absolute; right:2px;\">
<form method=post action=s4.php class=pfind>
  <label for=\"find\"></label>
  <input type=\"text\" name=\"find\" id=\"find\" />
  <input name=\"search\" type=\"submit\" class=\"submit2\" id=\"search\" value=\"Search\" />
</form>
</div>";
if(isset($_GET['edit'])){
print("$dis");	
}

?>
<div style="position: absolute; left: 8px; top: 42px;">
<?php
include("conn.php");
if(isset($_POST['s4entry'])){
	//print("<br>Im Getting here<br>");
	$iselected=array();
	$issel=$_POST['selgrp'];
	for($i=0; $i<15; $i++){
	if($issel[$i]>0){
		$grp=$issel[$i];
		break;
	}
	}
	$dis="<h2 align=center>S4 Entry Form  For Group  \"$grp\"</h2>
<div align=center>
<style type=text/css>
table {
	align: center;
	
}
table.imagetable {

	font-family: verdana,arial,sans-serif;
	font-size:14px;
	color:#333333;
	border-width: 1px;
	border-color: #999999;
	border-collapse: collapse;
}
table.imagetable th {
	background:#b5cfd2 url(cell-blue.jpg);
	border-width: 1px;
	padding: 8px;
	border-style: solid;
	border-color: #999999;
}
table.imagetable td {
	background:#dcddc0 url(cell-grey.jpg);
	border-width: 1px;
	padding: 8px;
	border-style: solid;
	border-color: #999999;
}
input    {
width:80px;
display:block;
border: 1px solid #999;
height: 25px;
-webkit-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
}
input.s4reg    {
width:150px;
display:block;
border: 1px solid #999;
height: 25px;
-webkit-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
}
</style>
<form action=s4.php method=post ><table class=imagetable align=center>
<tr align=left>
	<th>No.</th>
	<th>First Name</th>
	<th>Last Name</th>
	<th>Priviledge</th>
	<th>Books</th>
	<th>Booklets</th>
	<th align=center>Hrs</th>
	<th>Magazines</th>
	<th>Return Visits</th>
	<th>Bible Study</th>
	<th>Comments</th>
</tr>";
	//$grp=$_POST['selgrp'];
	//$grp=5;
	$s="select * from publishers where pubgrpnum='$grp' and state=1 order by lname, fname asc";
	$r=mysql_query($s, $conn) or die(mysql_error());
	$cnt=0;
	if(mysql_num_rows($r)){
	while($t=mysql_fetch_array($r)){
		$id=$t['pubid'];
		$mnth=$_POST['mn'];
		$yr=$_POST['yr'];
		$q="select * from s4 where pubid='$id' and Month='$mnth' and yr='$yr'";
		$a=mysql_query($q,$conn) or die(mysql_error());
		if(mysql_num_rows($a)==0){
		$cnt++;
		$dis.="<tr>
		<td>$cnt</td>
		<td>$t[fname] <input type=hidden name=pid[] value=$t[pubid]</td>
		<td>$t[lname]</td>
		<td><select name=priv[]>
		<option value=0 selected=selected>Publisher</option>
		<option value=1>Auxilary Pioneer</option>
		<option value=2>Regular Pioneer</option>
		<option value=3>Special Pioneer</option>
		</select></td>
		<td><input type=text name=bks[] /></td>
		<td> <input type=text name=bklets[] /></td>
		<td align=center><input type=text name=hrs[] /></td>
		<td><input type=text name=magz[] /></td>
		<td><input type=text name=rv[] /></td>
		<td><input type=text name=bs[] /></td>
		<td><textarea name=com[]></textarea></td>
	</tr>";
		}
	}
	$dis.="<tr>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	<td><input type=hidden name=mn value=$mnth /><input type=hidden name=yr value=$yr /></td>
	<td><input type=hidden name=coun value=$cnt /></td>
	<td><input class=s4reg type=submit name=savs4 value=\"Save S4 Records\" /></td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	</tr>";
	print("$dis");
	//echo "<br><br>";
	}else{
	print("No record was found");	
	}
	//print("Im getting here");
	exit;
}

?>
</div>
<div style="position: absolute; left: 222px; top: 74px;">
<form class="gs4" action="s4.php" method="post">

<table width="733" cellspacing="1" cellpadding="3">
  <tr>
    <td width="90" height="37"><label>
      <input type="radio" name="selgrp[]" value="1" id="selgrp" />
      Group 1</label></td>
 
    <td width="110"><label>
      <input type="radio" name="selgrp[]" value="2" id="selgrp" />
      Group 2</label></td>
  
    <td width="190"><label>
      <input type="radio" name="selgrp[]" value="3" id="selgrp" />
      Group 3</label></td>
  
    <td width="189"><label>
      <input type="radio" name="selgrp[]" value="4" id="selgrp" />
      Group 4</label></td>
 
    <td width="116"><label>
      <input type="radio" name="selgrp[]" value="5" id="selgrp" />
      Group 5</label></td>
  </tr>
  <tr>
    <td height="44"><label>
      <input type="radio" name="selgrp[]" value="6" id="selgrp" />
      Group 6</label></td>
  
    <td><label>
      <input type="radio" name="selgrp[]" value="7" id="selgrp" />
      Group 7</label></td>
  
    <td><label>
      <input type="radio" name="selgrp[]" value="8" id="selgrp" />
      Group 8</label></td>
 
    <td><label>
      <input type="radio" name="selgrp[]" value="9" id="selgrp" />
      Group 9</label></td>
 
    <td><label>
      <input type="radio" name="selgrp[]" value="10" id="selgrp" />
      Group 10</label></td>
  </tr>
  <tr>
    <td height="53"><label>
      <input type="radio" name="selgrp[]" value="11" id="selgrp" />
      Group 11</label></td>
 
    <td><label>
      <input type="radio" name="selgrp[]" value="12" id="selgrp" />
      Group 12</label></td>
  
    <td><label>
      <input type="radio" name="selgrp[]" value="13" id="selgrp" />
      Group 13</label></td>
  
    <td><label>
      <input type="radio" name="selgrp[]" value="14" id="selgrp" />
      Group 14</label></td>
 
    <td><label>
      <input type="radio" name="selgrp[]" value="15" id="selgrp" />
      Group 15</label></td>
  </tr>
   <tr>
  <td height="55"></td>
  <td></td>
  <td><input name="mn" type="text" class="period" placeholder="Enter Month: e.g 05 for May" required="required"/></td>
  <td><input name="yr" type="text" class="period" placeholder="Enter Year" required="required" /></td>
  <td></td>
  </tr>
  <tr>
  <td height="51"></td>
  <td></td>
  <td><input name="s4entry" type="submit" class="subgs4" value="Show Group Entry Form" /></td>
  <td></td>
  <td></td>
  </tr>
</table>
</form>
</div>

<div style="position:absolute;">
<?php
include("conn.php");
if(isset($_POST['savs4'])){
	$m=$_POST['mn'];
	$yr=$_POST['yr'];
	$cc=$_POST['coun'];
	$pid=array();
	$pid=$_POST['pid'];
	$bk=array();
	$bk=$_POST['bks'];
	$bklets=array();
	$bklets=$_POST['bklets'];
	$hrs=array();
	$hrs=$_POST['hrs'];
	$magz=array();
	$magz=$_POST['magz'];
	$rv=$_POST['rv'];
	$bs=array();
	$bs=$_POST['bs'];
	$com=array();
	$com=$_POST['com'];
	$priv=array();
	$priv=$_POST['priv'];
	$k=0;
	for($i=0; $i<$cc; $i++){
		if(is_numeric($hrs[$i]) and $hrs[$i]>0){
$s="insert into s4 values(now(),'$pid[$i]', '$m', '$yr','$bk[$i]','$bklets[$i]','$hrs[$i]','$magz[$i]','$rv[$i]','$bs[$i]','$priv[$i]', '$com[$i]')";
mysql_query($s,$conn) or die(mysql_error());
$k++;
		}
	}
	print("<br><font color=#660099><strong>$k of $cc records Successfully Saved!!!</strong></font><br>");
}
?>
</div>

</body>
</html>